import request from 'src/utils/request.js'

// 获取菜单列表
export function gainMenuList() {
  return request({
    url: '/rbac/permissions/menu/',
    method: 'get'
  })
}

// 查询页面访问权限
export function gainPerPage(query) {
  return request({
    url: '/rbac/permissions/page/',
    method: 'get',
    params: query
  })
}

// 查询页面元素访问权限
export function gainPerEle(query) {
  return request({
    url: '/rbac/permissions/element/',
    method: 'get',
    params: query
  })
}

// 获取公司列表-权限配置
export function gainCompanyList(query) {
  return request({
    url: '/organizer/companys/list/',
    method: 'get',
    params: query
  })
}

// 获取角色列表-权限配置
export function gainRolesList(query) {
  return request({
    url: '/rbac/roles/',
    method: 'get',
    params: query
  })
}

// 增加角色 - 权限配置
export function addRolesList(data) {
  return request({
    url: '/rbac/roles/',
    method: 'post',
    data
  })
}
// 修改角色 - 权限配置
export function updateRolesList(id, data) {
  return request({
    url: `/rbac/roles/${id}/`,
    method: 'put',
    data
  })
}
// 删除角色 - 权限配置
export function deleteRolesList(id) {
  return request({
    url: `/rbac/roles/${id}/`,
    method: 'delete'
  })
}

// 获取菜单权限 - 权限配置
export function gainRolesPermission(query) {
  return request({
    url: '/rbac/roles/permissions/',
    method: 'get',
    params: query
  })
}

// 修改菜单权限 - 权限配置
export function updateRolesPermission(id, data) {
  let _url
  if (id) {
    _url = `/rbac/roles/permissions/${id}/`
  } else {
    _url = `/rbac/roles/permissions/`
  }
  return request({
    url: _url,
    method: 'put',
    data
  })
}


